home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
borland
/
bgidriv.zip
/
DEBUG.C
< prev
next >
Wrap
Text File
|
1989-06-20
|
47KB
|
1,345 lines
/*
DEBUG.C - sample debugging BGI driver
Copyright (c) 1988,89 Borland International
*/
#include <stdlib.h>
#include <string.h>
#include <dos.h>
/* ----------------------------- DEBUG.C ------------------------------ */
/* */
/* Function Protoypes for the debug driver. */
/* */
void save_regs( void );
void banner( char *str );
void putnum( unsigned number );
void puthex( unsigned number );
void dputs( char far *str );
void crlf( void );
void far enter_graphics( void );
void far leave_graphics( void );
void far putpix( void );
void far getpix( void );
void far bits_per_pixel( void );
void far set_visual( void );
void far set_page( void );
void far set_write_mode( void );
typedef void far (*FRFPTR)( void ); /* Pointer to Void/Void Funct */
typedef void (*NRFPTR)( void ); /* Pointer to Void/Void Funct */
/* */
/* The following C structure defines a Device Status Block. */
/* */
typedef struct {
unsigned char stat; /* Current device status. */
unsigned char devtype; /* Device Type Identifier. */
unsigned int xres; /* Device Full Resolution in X */
unsigned int yres; /* Device Full Resolution in Y */
unsigned int xefres; /* Device Effective X Resolution*/
unsigned int yefres; /* Device Effective Y Resolution*/
unsigned int xinch; /* Device X Size in inches*1000 */
unsigned int yinch; /* Device Y Size in inches*1000 */
unsigned int aspec; /* Aspect Ratio * 10000 */
unsigned char chsizx; /* Standard char size X */
unsigned char chsizy; /* Standard char size Y */
unsigned char fcolors; /* Number of foreground colors */
unsigned char bcolors; /* Number of background colors */
} STATUS;
/* */
/* The following structure defines a palette record. */
/* */
typedef struct {
unsigned char length; /* # of color entries in palette*/
unsigned char color[16]; /* Up to 16 color entries */
} PALETTE;
/* */
/* The following structure defines a utility function table. */
/* */
typedef struct {
NRFPTR goto_graph; /* Enter graphics mode function */
NRFPTR exit_graph; /* Leave graphics mode function */
NRFPTR putpix; /* Write a pixel function */
NRFPTR getpix; /* Read a pixel function */
NRFPTR bits_per_pixel; /* Bits per pixel value */
NRFPTR set_page; /* Set the active drawing page */
NRFPTR set_visual; /* Set the active display page */
NRFPTR write_mode; /* Set the current write mode */
} UTILITIES;
/* */
/* This status block declares the debug driver to appear as an */
/* EGA card in high resolution mode. */
/* */
STATUS Stat_Block = { /* Status block to fake an EGA driver */
0, /* Current device status. */
0, /* Device Type Identifier. */
639, /* Device Full Resolution in X */
479, /* Device Full Resolution in Y */
639, /* Device Effective X Resolution */
479, /* Device Effective Y Resolution */
9000, /* Device X Size in inches*1000 */
7000, /* Device Y Size in inches*1000 */
10000, /* Aspect Ratio * 10000 */
8 + 0x80, /* Standard char size X */
8 + 0x80, /* Standard char size Y */
16 + 0x80, /* Number of foreground colors */
16 + 0x80 /* Number of background colors */
};
/* */
/* This palette declares the default EGA palette. */
/* */
PALETTE Default_Palette = { /* Define the palette for above EGA mode*/
16, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F }
};
/* */
/* The following structure defines the Bit Manipulation Utility */
/* function table. */
/* */
UTILITIES Utility_Table = { /* Bit Utilities Function Table */
(NRFPTR) enter_graphics, /* Enter graphics mode function */
(NRFPTR) leave_graphics, /* Leave graphics mode function */
(NRFPTR) putpix, /* Write a pixel function */
(NRFPTR) getpix, /* Read a pixel function */
(NRFPTR) bits_per_pixel, /* Bits per pixel function */
(NRFPTR) set_page, /* Set the active drawing page */
(NRFPTR) set_visual, /* Set the active display page */
(NRFPTR) set_write_mode /* Set the current write mode */
};
/* */
/* The following defines the name of the modes for Driver. */
/* NOTE: The string must start with a PASCAL style length. */
/* */
char Name[] = "\030Debug Driver (640 x 480)";
/* Driver Local Data Variables */
char Buffer[80] = { 0 }; /* String output buffer */
unsigned int CP_X = 0, CP_Y = 0; /* Current Drawing Pointer CP */
unsigned int ds = 0; /* DS on entry to the driver */
unsigned int ax = 0, bx = 0, cx = 0, dx = 0;
unsigned int ah = 0, bh = 0, ch = 0, dh = 0;
unsigned int al = 0, bl = 0, cl = 0, dl = 0;
/* ----------------------------- INSTALL ------------------------------- */
/* */
/* The Install function is used to prepare the driver to use. */
/* The calls to this function allow the kernal to inquire the */
/* mode information, and allow the kernal to install the mode */
/* infomation. */
/* */
void install( void )
{
save_regs(); /* Save a copy of current regs */
banner( "INSTALL" ); /* Announce the function type */
switch( al ){ /* Determine the command to use */
case 0: /* Install Device Command */
dputs( " Install Device: Mode Number: " );
putnum( cl );
dputs( " AutoDetect Maxi